<!DOCTYPE HTML>
<html>
<head>
    <include file="Common:header_include"/>
    <title>编辑用户角色</title>
</head>
<body>
<div class="pd-20">
    <form action="{:U('edit')}" method="post" class="form form-horizontal" id="form">
        <input type="text" name="id" value="{$data.id}" hidden>
        <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>名称：</label>
            <div class="formControls col-8">
                <input type="text" class="input-text" placeholder="请输入" name="title" datatype="*" nullmsg="不能为空" value="{$data.title}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-2"><span class="c-red"></span>描述：</label>
            <div class="formControls col-8">
                <textarea name="content" class="textarea" placeholder="请输入">{$data.content}</textarea>
            </div>
        </div>
        <div class="row cl" style="height:120px;">
            <label class="form-label col-2"><span class="c-red"></span>后台菜单：</label>
            <div class="formControls col-8">
                <table class="table table-border table-bordered table-hover table-bg">
                    <tr>
                        <td width="100" class="text-c">选择</td>
                        <td width="200" class="text-c">菜单</td>
                        <td class="text-c">菜单说明</td>
                    </tr>
                    <volist name=":getMenuTree()" id="item">
                        <?php
                        if($item['menu_id'] == 0){
                           $levelId = $item['id'];
                        }
                        ?>
                        <tr>
                            <td class="text-c"><input type="checkbox" name="menu[]" id="level{$item.menu_id}" class="menuClass{$levelId}" value="{$item.id}" <if condition="in_array($item['id'],json_decode($data['menu']))">checked</if> ></td>
                            <td>{$item.title}</td>
                            <td>{$item.content|default='暂无说明'}</td>
                        </tr>
                    </volist>
                </table>
            </div>
        </div>
        <div class="row cl">
            <div class="col-8 col-offset-2">
                <input class="btn btn-primary radius" type="submit" value="提交">
            </div>
        </div>
    </form>
</div>
</div>
<include file="Common:footer_include"/>
<script>
    $("input[type='checkbox']").click(function() {
        var selId = $(this).attr('id');
        var selClass = $(this).attr('class');
        if (selId == 'level0') {
            //全选或取消
            var isChecked = $(this).is(":checked");
            $('.' + selClass).prop('checked', isChecked);
        }
    });
</script>
</body>
</html>